package com.simblog.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSONObject;
import com.simblog.common.constants.Constants;
import com.simblog.oaknt.domain.AreaDict;
import com.simblog.oaknt.service.IAreaDictService;

@Controller
@RequestMapping("p/area")
public class AreaDictController extends BaseController {
	private Logger logger = LoggerFactory.getLogger(AreaDictController.class);
	@Reference
	IAreaDictService areaDictService;

	@ResponseBody
	@RequestMapping(value = "query", params = "pid")
	public JSONObject query(String pid) {
		logger.info("查询地区数据字典，pid={}", pid);
		List<AreaDict> list = null;
		Map<String, Object> params = new HashMap<String, Object>();
		try {
			params.put("pid", pid);
			list = areaDictService.queryList(params);
			return assemblyJson(list, Constants.RESP_SUCCESS, "地区数据字典获取成功");
		} catch (Exception e) {
			logger.error("查询地区数据字典异常" + e.getMessage());
			e.printStackTrace();
			return assemblyJson(null, Constants.RESP_EXCEPTION, "系统异常");
		}
	}
}
